package com.example.demo.file.service.impl;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.Map;

import org.apache.ibatis.javassist.expr.NewArray;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.StringUtils;

import com.example.demo.common.CommonUtil;
import com.example.demo.file.dao.FileUploadMapper;
import com.example.demo.file.pojo.FileUpload;
import com.example.demo.file.service.FileService;

/**
 * 
 * <p>
 * 功能描述： 文件管理Service 实现类
 * </p>
 * 
 * @author lixh
 * @date 2019年2月20日 下午5:40:24
 * @company chinobot
 * @version 1.0
 */
@Service
@Transactional
public class FileServiceImpl implements FileService {

	@Autowired
	private FileUploadMapper fileuploadmapper;

	@Override
	public List<FileUpload> getFileList(Map<String, Object> map) {
		return null;
	}

	@Override
	public FileUpload getFileUpload(String id) {
		if (StringUtils.isEmpty(id)) {
			return new FileUpload();
		}
		return fileuploadmapper.selectByPrimaryKey(id);
	}

	@Override
	public FileUpload getFileUpload(FileUpload fileupload) {
		return null;
	}

	@Override
	public Integer AddFile(FileUpload fileupload) {
		if (StringUtils.isEmpty(fileupload)) {
			return 0;
		}
		SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
		fileupload.setCreatetime(CommonUtil.getStringToDate(null, format.format(new Date())));
		fileupload.setUpdatetime(CommonUtil.getStringToDate(null, format.format(new Date())));
		return fileuploadmapper.insert(fileupload);
	}

}
